package com.yuntsg.nnsfcp.util;

import cn.hutool.core.util.ReflectUtil;
import lombok.SneakyThrows;

import java.lang.reflect.Field;

public class ClassUtil {


    @SneakyThrows
    /**
     * 根据类的属性获取值使用的
     * 2024年8月9日13:15:53
     */
    public static Object getClassFieldValue(Object oparam, String fieldName) {
        Class<?> aClass = oparam.getClass();
        try {
            Field field = ReflectUtil.getField(aClass, fieldName);
            Object ort = oparam;
            Object o = field.get(ort);
            return o;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
//        Field[] declaredFields = ort.getClass().getDeclaredFields();
//        for (Field declaredField : declaredFields) {
//            String name = declaredField.getName();
//
//        }
    }
}
